package com.shop.goods.service.impl;

import java.util.List;
import com.shop.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.shop.goods.mapper.ShopCartMapper;
import com.shop.goods.domain.ShopCart;
import com.shop.goods.service.IShopCartService;

/**
 * 购物车数据Service业务层处理
 * 
 * @author wuhao
 * @date 2022-04-07
 */
@Service
public class ShopCartServiceImpl implements IShopCartService 
{
    @Autowired
    private ShopCartMapper shopCartMapper;

    /**
     * 查询购物车数据
     * 
     * @param id 购物车数据主键
     * @return 购物车数据
     */
    @Override
    public ShopCart selectShopCartById(Long id)
    {
        return shopCartMapper.selectShopCartById(id);
    }

    /**
     * 查询购物车数据列表
     * 
     * @param shopCart 购物车数据
     * @return 购物车数据
     */
    @Override
    public List<ShopCart> selectShopCartList(ShopCart shopCart)
    {
        return shopCartMapper.selectShopCartList(shopCart);
    }

    /**
     * 获取我的购物车信息
     * @param shopCart
     * @return
     */
    @Override
    public List<ShopCart> selectMyCart(ShopCart shopCart) {
        return shopCartMapper.selectMyCart(shopCart);
    }

    /**
     * 新增购物车数据
     * 
     * @param shopCart 购物车数据
     * @return 结果
     */
    @Override
    public int insertShopCart(ShopCart shopCart)
    {
        shopCart.setCreateTime(DateUtils.getNowDate());
        return shopCartMapper.insertShopCart(shopCart);
    }

    @Override
    public int addCart(ShopCart shopCart)  {
        return shopCartMapper.addCart(shopCart);
    }

    /**
     * 修改购物车数据
     * 
     * @param shopCart 购物车数据
     * @return 结果
     */
    @Override
    public int updateShopCart(ShopCart shopCart)
    {
        shopCart.setUpdateTime(DateUtils.getNowDate());
        return shopCartMapper.updateShopCart(shopCart);
    }

    /**
     * 批量删除购物车数据
     * 
     * @param ids 需要删除的购物车数据主键
     * @return 结果
     */
    @Override
    public int deleteShopCartByIds(Long[] ids)
    {
        return shopCartMapper.deleteShopCartByIds(ids);
    }

    /**
     * 删除购物车数据信息
     * 
     * @param id 购物车数据主键
     * @return 结果
     */
    @Override
    public int deleteShopCartById(Long id)
    {
        return shopCartMapper.deleteShopCartById(id);
    }
}
